package com.ay.weixin.fdc.boss.blog.db;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lizar.db.ibatis.Dao;

import com.ay.weixin.fdc.boss.blog.domain.Blog;
import com.ay.weixin.fdc.boss.share.domain.ShareActivity;

public class BlogDao extends Dao {
	public List<ShareActivity> getByStatus(long wxproject_id,int status) throws SQLException{
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("wxproject_id",wxproject_id);
		map.put("status",status);
		return (List<ShareActivity>)this.sqlMapper.queryForList("blog.getByStatus",map);
	}
	
	public void insert(Blog blog) throws SQLException{
		this.sqlMapper.insert("blog.insert",blog);
	}
	
	public void update(Blog blog) throws SQLException{
		this.sqlMapper.update("blog.update",blog);
	}
	
	public List<Blog> getAllTop50(long wxproject_id) throws SQLException{
		return (List<Blog>)this.sqlMapper.queryForList("blog.getAllTop50",wxproject_id);
	}
	
	public void update_status(long id,int status) throws SQLException{
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("id",id);
		map.put("status",status);
		this.sqlMapper.update("blog.update_status",map);
		
	}
	
	public void delete(long id) throws SQLException{
		this.sqlMapper.delete("blog.delete",id);
	}
	
	
	
	public Blog getById(long id) throws SQLException{
		return (Blog)this.sqlMapper.queryForObject("blog.getById",id);
	}
}
